import axios from "axios";

const fileHttp = axios.create({
  headers: {
    "X-Requested-With": "XMLHttpRequest",
    "Content-Type": "multipart/form-data",
  },
});

fileHttp.uploadImage = (data) => {
  var imageFiles = data;
  var formData = new FormData();
  var length = imageFiles.length;
  while (length--) {
    formData.append("upload", imageFiles[length]);
    formData.append("width", "");
    formData.append("height", "");
    formData.append("maxWidth", "");
    formData.append("minWidth", 50);
    formData.append("maxHeight", "");
    formData.append("minHeight", 50);
    formData.append("maxSize", 5);
    formData.append("formats", "PNG, JPEG, JPG, GIF");
  }
  return fileHttp.post("/modeling/uploadimg", formData);
};
fileHttp.uploadFile = (url, params) => {
  var formData = new FormData();
  for (const [key, value] of Object.entries(params)) {
    formData.append(key, value);
  }
  return fileHttp.post(url, formData);
};
export default fileHttp;
